<!--
 * @Author: wangding
 * @Date: 2020-11-11 15:58:31
 * @LastEditTime: 2020-12-04 16:57:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\device\sale\add.vue
-->
<template>
    <div class="buyPage-main-box-add">
        <el-dialog
        :title="$t('inventoryManage.recordInstall')"
        :visible="rightVisibleEdit"
        width="35%"
        @close="()=>{$store.commit('setRightVisibleEdit',false)}"
        :close-on-click-modal='false'
        >   
            <el-row :gutter="20">
                <el-col :span="19" :offset="2">
                    <el-form ref="form" :model="form" label-width="120px" >
                        <el-form-item :label="$t('inventoryManage.inventoryNumber')" prop="number" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                            <el-input v-model="form.number" style="width:100%"  :placeholder="$t('pleaseSelect')" :disabled="returnStatusNumber">
                            </el-input>
                        </el-form-item>
                    </el-form>
                </el-col>
            </el-row>
            <span slot="footer" class="dialog-footer">
                <el-button @click="()=>{$store.commit('setRightVisibleEdit',false)}">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="!returnStatusNumber?save('form'):wmsstockInstallProduct()">{{$t('sure')}}</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    components: {
    },
    props: {
        editRow:{
            type:Object,
            default:{}
        },
        returnStatusNumber:{
            type:Boolean
        }
    },
    data() {
        return {
            typeList:[{
                id:'0',
                text:"VPP"
            },{
                id:'1',
                text:"SAPN"
            }],
            form:{
                number:"",
            },
        };
    },
    computed: {
        rightVisibleEdit(){
            return this.$store.state.sysStore.rightVisibleEdit
        }
    },
    watch: {

    },
    created() {

    },
    mounted() {

    },
    methods: {
        async wmsstockInstallProduct(){
            let res = await this.API.wmsstockInstallProduct(Object.assign({},this.form,{sn:this.editRow.sn}))
            if(!res.success){
                if(res.object == 1){
					this.comm.showMsg(false,this.$t('inventoryManage.erroyInstall'))
				}else{
                    this.comm.showMsg(false,this.$t('index.control_fail'))
				}
            }else{
                this.comm.showMsg(true,this.$t('index.control_success'))
                this.$store.commit('setRightVisibleEdit',false)
                this.$emit('uploadData',true)
            }
        },
        save(formName){
            this.$refs[formName].validate((valid) => {
              if (valid) {
                  this.wmsstockInstallProduct()
              } else {
                console.log('error submit!!');
                return false;
              }
            });
        },
    },
};
</script>

<style  lang="less" >
.buyPage-main-box-add{
    .el-form-item__content{
        display: flex;
    }
    .icon-fontsize{
        font-size: 25px;
        margin-left: 10px;
        display: block;
        width: 25px;
        height: 33px;
    }
}
</style>
